package com.mdd.front.controller.yangyangLeadingEnterprise.index;

import com.mdd.common.aop.NotLogin;
import com.mdd.common.entity.yangyangLeadingEnterprise.common.JsonReturn;
import com.mdd.common.entity.yangyangLeadingEnterprise.dto.AppCourseDTO;
import com.mdd.common.entity.yangyangLeadingEnterprise.param.AppCourseParam;
import com.mdd.front.service.yangyangLeadingEnterprise.ITAppCourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("api.index/course")
@Api(tags = "app首页---商学院管理")
public class TAppCourseController {

    @Resource
    ITAppCourseService appCourseService;

//    @GetMapping("/list")
//    @ApiOperation(value="课程列表")
//    public AjaxResult<PageResult<TAppCourseListedVo>> list(@Validated PageValidate pageValidate,
//                                                     @Validated TAppCourseSearchValidate searchValidate) {
//        PageResult<TAppCourseListedVo> list = iTAppCourseService.list(pageValidate, searchValidate);
//        return AjaxResult.success(list);
//    }

    /**
     * 商学院---课程列表
     * @return
     */
    @NotLogin
    @PostMapping(value = "/index",produces = "application/json; charset=UTF-8")
    @ApiOperation(value="课程列表")
    public String index(HttpServletRequest request) {
        //热门课程
        AppCourseParam param = new AppCourseParam();
        param.setAmount(2);
        param.setType(1);
        List<AppCourseDTO> courseList = appCourseService.selecList(param);
        //其他课程
        AppCourseParam paramData = new AppCourseParam();
        paramData.setAmount(4);
        paramData.setType(2);
        List<AppCourseDTO> otherCourseList = appCourseService.selecList(paramData);
        return JsonReturn.success().put("courseList",courseList).put("otherCourseList",otherCourseList).toJsonStr();
    }


}
